<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateWander extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('wander', array('engine' => 'MyISAM', 'comment' => '流转表单'));
        $table
            ->addColumn('title', 'string', array('limit' => 120, 'null' => true, 'comment' => '流转单标题'))
            ->addColumn('describe', 'string', array('limit' => 120,'null' => true, 'comment' => '描述内容'))
            ->addColumn('content', 'string', array('limit' => 120,'null' => true, 'comment' => '办公用品及其他'))
            ->addColumn('promoter_id', 'integer', array('limit' => 11, 'null' => true, 'comment' => '发起人'))
            ->addColumn('abutment_group_id', 'integer', array('limit' => 11, 'null' => true, 'comment' => '对接部门'))
            ->addColumn('abutment_id', 'integer', array('limit' => 11, 'null' => true, 'comment' => '对接人'))
            ->addColumn('is_superior', 'boolean', array('limit' =>1, 'default' => 0,'null' => true, 'comment' => '是否需要上级审核(0不需要,1需要)'))
            ->addColumn('superior_id', 'integer', array('limit' =>11, 'default' => 0,'null' => true, 'comment' => '上级审核id'))
            ->addColumn('begin_time', 'datetime', array('null' => true, 'comment' => '开始时间'))
            ->addColumn('end_time', 'datetime', array('null' => true, 'comment' => '结束时间'))
            ->addColumn('finish_status', 'boolean', array('limit' => 1, 'default' => 0, 'comment' => '完成状态(0.待审核,1.流程中,2.完成,-1：退回)'))
            ->addColumn('status', 'boolean', array('limit' => 1, 'default' => 1, 'comment' => '状态(0禁用,1正常)'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();



        $table = $this->table('wander_record', array('engine' => 'MyISAM', 'comment' => '流转表单记录表'));
        $table->addColumn('wander_id', 'integer', array('limit' => 11, 'null' => true, 'comment' => '流转表单id'))
            ->addColumn('btn', 'string', array('limit' => 120,'null' => true, 'comment' => '提交操作信息'))
            ->addColumn('run_id', 'integer', array('limit' => 11, 'null' => true, 'comment' => '流程步骤id'))
            ->addColumn('examine_status', 'boolean', array('limit' => 1, 'default' => 0, 'comment' => '审核状态(0.待审核,1.流程中,2.完成,-1：退回)'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();
    }
}
